cmake_minimum_required(VERSION 3.0.0)
project(container VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party)

add_subdirectory(${THIRD_PARTY_DIR}/fmt-10.2.1)
add_subdirectory(${THIRD_PARTY_DIR}/gflags)

set(RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resource)
set(MINIFS_DIR ${RESOURCE_DIR}/minifs.tar.gz)

add_executable(container main.cpp container.cpp)
target_link_libraries(container fmt gflags::gflags)
target_include_directories(container PRIVATE ${THIRD_PARTY_DIR}/toml11)
target_compile_options(container PRIVATE -Werror )

add_custom_target(copy_resources ALL
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${RESOURCE_DIR} $<TARGET_FILE_DIR:container>/resources
)

add_dependencies(copy_resources container)

install(TARGETS container DESTINATION bin)
install(DIRECTORY ${RESOURCE_DIR}/ DESTINATION resources)
